﻿using IBLL;
using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class LoginBLL : LoginIBLL
    {
        public LoginBLL(IBaseDAL<Login> Db)
        {
            this.Db = Db;
        }

        public IBaseDAL<Login> Db { get; }

        public Login Deng(string name, string pwd)
        {
            var a = Db.GetAll().FirstOrDefault(x => x.UserName == name);
            if (a == null)
            {
                a = new Login() { LoginId = -1 };
            }
            else
            {
                if (a.Password != pwd)
                {
                    a = new Login() { LoginId = -2 };
                }
                else
                {
                    if (a.State == false)
                    { 
                        a = new Login() { LoginId = -3 };
                    }
                }
            }
            return a;
        }
    }
}
